﻿using System;
using System.Collections.Generic;
using System.Text;
using Lswweb.Model;

namespace Lswweb.IDAL
{
    public interface IUsers
    {
        /// <summary>
        /// 插入用户表信息
        /// </summary>
        /// <param name="info">实体类</param>
        /// <returns>返回用户Id</returns>
        int Insert(UserInfo info);

        /// <summary>
        ///判断用户名是否存在 
        /// </summary>
        /// <param name="id">用户id,可以为0</param>
        /// <param name="name">用户登陆名字</param>
        /// <returns>false不存在，true存在</returns>
        bool IsHas(int id, string name);

        /// <summary>
        /// 用户更改密码
        /// </summary>
        /// <param name="loginName">用户名</param>
        /// <param name="newPsw">新密码</param>
        /// <returns></returns>
        bool UpdatePsw(int id, string newPsw);

        /// <summary>
        /// 更新用户表信息信息
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        bool Update(UserInfo info);

        /// <summary>
        /// 更新用户状态
        /// </summary>
        /// <param name="id"></param>
        /// <param name="type"></param>
        bool UpdateStatus(int id, StatusType type);

        /// <summary>
        /// 删除用户表信息信息
        /// </summary>
        /// <param name="id">用户表ID</param>
        /// <returns></returns>
        bool Delete(int id);


        /// <summary>
        /// 根据用户名取得用户实体类
        /// </summary>
        /// <param name="name">users表的用户名</param>
        /// <returns></returns>
        UserInfo GetUser(string name);
        /// <summary>
        /// 根据用户id取得用户实体类
        /// </summary>
        /// <param name="id">用户id</param>
        /// <returns></returns>
        UserInfo GetUser(int id);

        /// <summary>
        /// 用户搜索
        /// </summary>
        /// <param name="searchKey">搜索关键字节，可以为空值</param>
        /// <param name="statusType">用户状态，可以为非当前枚举中的值</param>
        /// <param name="pageSize">每页记录条数</param>
        /// <param name="pageIndex">页数</param>
        /// <param name="record">总记录条数</param>
        /// <returns>用户集合</returns>
        IList<UserInfo> GetUsers(string searchKey, StatusType statusType, RoleType roleType,int pageSize, int pageIndex, out int record);

        #region UserProfile

        /// <summary>
        /// 取得会员资料
        /// </summary>
        /// <param name="userId">会员id</param>
        /// <returns></returns>
        UserProfileInfo GetProfile(int userId);

        bool UpdateProfile(UserProfileInfo profileInfo);

        #endregion

        #region AdminUsers

        string GetAdminPowers(int id);

        /// <summary>
        /// 修改管理员权限
        /// </summary>
        /// <param name="id"></param>
        /// <param name="powerStr"></param>
        bool UpdateAdminPowers(int id, string powerStr);

        /// <summary>
        /// 修改用户是否为管理员
        /// </summary>
        /// <param name="userName">用户名</param>
        /// <param name="isAdmin">是否为管理员</param>
        bool UpdateIsAdmin(string userName, bool isAdmin);

        #endregion
    }
}

